<!-- editProfile -->
<template>
  <div class="container">
    <ch-list :title="'编辑个人信息'"></ch-list>
    <el-form style="margin-top: 20px" label-position="left" label-width="50px" class="form">
      <el-form-item label="昵称" size="small">
        <el-input :width="300" v-model="userInfo.name" :disabled="true"></el-input>
      </el-form-item>
      <el-form-item label="密码" size="small">
        <el-input v-model="userInfo.password"></el-input>
      </el-form-item>
      <el-form-item label="邮箱" size="small">
        <el-input v-model="userInfo.email"></el-input>
      </el-form-item>
      <el-form-item size="small">
          <el-button type="primary" size="small" @click="save">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'editProfile',
  data() {
    return {
      userInfo: {}
    }
  },
  methods: {
    save() {
      this.$post('/users/save', {
        name: this.userInfo.name,
        password: this.userInfo.password || null,
        email: this.userInfo.email || null
      })
    }
  },
  created() {

  },
  mounted() {
    this.userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
  }
}
</script>
<style lang='scss' scoped>
// @import ''
.container {
  margin: 30px 100px;
  width: 60vw;
  display: flex;
  justify-content: center;
  flex-flow: column;

  .form {
    width: 300px;
  }

  .avatar {
    border: #ccc solid 5px;
  }
}
</style>
